package com.yonyou.pmclouds.basecom.view;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 包装业务异常，返回给前端
 */
@Data
public class BuziExWrapObject extends WrapViewObject {

    private String exMsg;

    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    private String exCode;

    @JsonInclude(value = JsonInclude.Include.NON_EMPTY, content = JsonInclude.Include.NON_EMPTY)
    private Map<String, String> additionInfo = new HashMap<>();

    public BuziExWrapObject() {
        this(null);
    }

    public BuziExWrapObject(String exMsg) {
        this(WrapViewObject.RESULT_BUSI_EX, exMsg);
    }

    public BuziExWrapObject(String resultCode, String exMsg) {
        this(resultCode, exMsg, null);
    }

    public BuziExWrapObject(String resultCode, String exMsg, String exCode) {
        setResultCode(resultCode);
        this.exMsg = exMsg;
        this.exCode = exCode;
    }

    public void setAdditionInfo(Map<String, String> additionInfo) {
        this.additionInfo.clear();
        if (additionInfo != null) {
            this.additionInfo.putAll(additionInfo);
        }
    }

}
